import * as Cesium from 'cesium'

export default function addRadar() {
  const material = new Cesium.Material({
    fabric: {
      source: `
      #define PI 3.1415926535897932384626433832795
      czm_material czm_getMaterial(czm_materialInput materialInput)
      {
        czm_material m = czm_getDefaultMaterial(materialInput);
        float strength = atan(materialInput.st.x - 0.5, materialInput.st.y - 0.5);
        strength = (strength + PI) / (2.0 * PI);
        m.diffuse = vec3(strength);
        m.specular = 0.5;
        return m;
      }
      `
    }
  })
  const appearance = new Cesium.EllipsoidSurfaceAppearance({
    material,
    aboveGround: true
  })
  const primitive = new Cesium.Primitive({
    geometryInstances: [
      new Cesium.GeometryInstance({
        geometry: new Cesium.CircleGeometry({
          center: Cesium.Cartesian3.fromDegrees(100, 30),
          radius: 100000,
          ellipsoid: Cesium.Ellipsoid.WGS84
        }),
      })
    ],
    appearance
  })
  window.viewer.scene.primitives.add(primitive)
}
